@(currentPage: Page[Supervisor], currentSortBy: String, currentOrder: String)

@****************************************
* Helper generating navigation links    *
****************************************@
@link(newPage:Int, newSortBy:String) = @{
    var sortBy = currentSortBy
    var order = currentOrder
    
    if(newSortBy != null) {
        sortBy = newSortBy
        if(currentSortBy == newSortBy) {
            if(currentOrder == "asc") {
                order = "desc"
            } else {
                order = "asc"
            }
        } else {
            order = "asc"
        }
    }
    
    // Generate the link
    routes.Admin.supervisors(newPage, sortBy, order)
}

@**********************************
* Helper generating table headers *
***********************************@
@header(key:String, title:String) = {
    <th class="@key.replace(".","_") header @if(currentSortBy == key) @{if(currentOrder == "asc") "headerSortDown" else "headerSortUp"}">
        <a href="@link(0, key)">@title</a>
    </th>
}

@main("admin")("supervisors"){
        	<div class="span10">
				<div class="btn-toolbar">
	        	    <div class="btn-group">
					    <a class="btn btn-info" href="@routes.Admin.supervisors()" rel="tooltip" title="@Messages("admin.supervisors.links.list")"><i class="icon-list-alt"></i></a>
				    </div>
				    @if(session.get("level") == "WRITE" ||session.get("level") == "ADMIN"  ) {
	        	    <div class="btn-group">
					    <a class="btn" href="@routes.Admin.newsupervisor()" rel="tooltip" title="@Messages("admin.supervisors.links.new")"><i class="icon-file"></i></a>
				    </div>                   
				    }
				</div>
				<h3>@Messages("admin.supervisors.header")</h3>
				<a class="btn pull-right" href="@routes.Admin.supervisors(-2, "ip", "asc")" rel="tooltip" title="@Messages("common.deleteprefs")"><i class="icon-trash"></i></a>
				<br/>
				<br/>
			    @if(currentPage.getTotalRowCount == 0) {
			        
			        <div class="well">
			            <em>@Messages("common.nothingtoshow")</em>
			        </div>
			        
			    } else {
				<table class="table table-striped table-bordered table-condensed">  
			        <thead>  
			          <tr>
			          	@header("name",Messages("common.name"))
			          	@header("host",Messages("common.host"))
			            @header("place",Messages("common.place"))
			          	@header("authentification",Messages("common.authentification"))
			          	@header("group.name",Messages("common.group"))
			            @header("comment",Messages("common.comment"))
			          	<th colspan="2">Action</th>
			          </tr>  
			        </thead>  
			        <tbody>  
					@for(supervisor <- currentPage.getList) {
			          <tr>  
			          
			            <td>@supervisor.name</td>  
			            <td>@supervisor.host</td>
			            <td>@supervisor.place</td>
			            <td>@if(supervisor.authentification == true) { <i class="icon-check"></i> } else { }</td>
			            <td>@if(supervisor.group != null) { @supervisor.group.name }</td>  
			            <td>@supervisor.comment</td>
			          	<td>@if(session.get("level") == "WRITE" ||session.get("level") == "ADMIN"  ) {<a href="@routes.Admin.editsupervisor(supervisor.id)"><i class="icon-edit"></i></a>}</td>
			            <td>@if(session.get("level") == "WRITE" ||session.get("level") == "ADMIN"  ) {<a href="@routes.Admin.deletesupervisor(supervisor.id)"><i class="icon-remove"></i></a>}</td>

			          </tr>  
					} 
			        </tbody>  
		      	</table>

		        <div id="pagination" class="pagination">
		            <ul>
		                @if(currentPage.hasPrev) {
		                    <li class="prev">
		                        <a href="@link(currentPage.getPageIndex - 1, null)">&larr; @Messages("common.previous")</a>
		                    </li>
		                } else {
		                    <li class="prev disabled">
		                        <a>&larr; @Messages("common.previous")</a>
		                    </li>
		                }
		                <li class="current">
		                    <a>Actuellement @currentPage.getDisplayXtoYofZ(" "+Messages("common.to")+" "," "+Messages("common.from")+" ")</a>
		                </li>
		                @if(currentPage.hasNext) {
		                    <li class="next">
		                        <a href="@link(currentPage.getPageIndex + 1, null)">@Messages("common.next") &rarr;</a>
		                    </li>
		                } else {
		                    <li class="next disabled">
		                        <a>@Messages("common.next") &rarr;</a>
		                    </li>
		                }
		            </ul>
		        </div>
		      	
		      	
		      	}
			</div>
}
